#! /bin/sh /usr/share/dpatch/dpatch-run
## 79_7776_black_background.dpatch by  <root@mythserver.home.rodriguez-vudoyra.com>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: No description.

@DPATCH@
diff -urNad mythtv-0.22.0-fixes22994~/libs/libmythtv/osd.cpp mythtv-0.22.0-fixes22994/libs/libmythtv/osd.cpp
--- mythtv-0.22.0-fixes22994~/libs/libmythtv/osd.cpp	2009-11-08 05:07:32.000000000 -0600
+++ mythtv-0.22.0-fixes22994/libs/libmythtv/osd.cpp	2009-12-22 23:10:52.000000000 -0600
@@ -324,7 +324,7 @@
     AddSet(container, name);
     OSDType708CC *ccpage = 
         new OSDType708CC(name, ccfonts, xoffset, yoffset, 
-                         displaywidth, displayheight);
+                         displaywidth, displayheight, wmult, hmult);
     container->AddType(ccpage);
 
     VERBOSE(VB_VBI, LOC + "InitCC708() -- end");
diff -urNad mythtv-0.22.0-fixes22994~/libs/libmythtv/osdtypes.cpp mythtv-0.22.0-fixes22994/libs/libmythtv/osdtypes.cpp
--- mythtv-0.22.0-fixes22994~/libs/libmythtv/osdtypes.cpp	2009-12-22 21:53:33.000000000 -0600
+++ mythtv-0.22.0-fixes22994/libs/libmythtv/osdtypes.cpp	2009-12-22 23:07:47.000000000 -0600
@@ -2601,7 +2601,8 @@
 }
 
 OSDType708CC::OSDType708CC(const QString &name, TTFFont *fonts[48],
-			   int xoff, int yoff, int dispw, int disph) : 
+                           int xoff, int yoff, int dispw, int disph,
+                           float wmult, float hmult) :
     OSDType(name)
 {
     xoffset = xoff;
@@ -2611,6 +2612,10 @@
 
     for (uint i = 0; i < 48; i++)
         m_fonts[i] = fonts[i];
+
+    QRect rect = QRect(0, 0, 0, 0);
+    m_box = new OSDTypeBox("cc_background", rect, wmult, hmult);
+    m_ccbackground = gContext->GetNumSetting("CCBackground", 0);
 }
 
 QRect OSDType708CC::CalcBounds(const OSDSurface *surface,
@@ -2748,24 +2753,34 @@
 
             font->CalcWidth(list[i]->str, &text_length);
 
-            font->setColor(list[i]->attr.GetFGColor(), kTTF_Normal);
-
             font->setOutline(false);
             font->setShadow(0,0);
-            if (list[i]->attr.edge_type == 3/*kEdgeUniform*/)
-            {
-                font->setColor(list[i]->attr.GetEdgeColor(), kTTF_Outline);
-                font->setOutline(true);
-            }
-            else if (list[i]->attr.edge_type == 4/*kEdgeLeftShadow*/)
-            {
-                font->setColor(list[i]->attr.GetEdgeColor(), kTTF_Shadow);
-                font->setShadow(-2, +2);
-            }
-            else if (list[i]->attr.edge_type == 5/*kEdgeRightShadow*/)
+            
+            if (m_ccbackground) 
             {
-                font->setColor(list[i]->attr.GetEdgeColor(), kTTF_Shadow);
-                font->setShadow(+2, +2);
+                QRect rect = QRect(0, 0, text_length + 1,
+                                   (font->Size() * 3 / 2) + 1);
+                m_box->SetRect(rect, m_wmult, m_hmult);
+                m_box->Draw(surface, 0, 0, ul.x() + tot_width - 2,
+                                           ul.y() + total_height - 2);
+                font->setColor(QColor(255, 255, 255), kTTF_Normal);
+            } else {
+                font->setColor(list[i]->attr.GetFGColor(), kTTF_Normal);
+                if (list[i]->attr.edge_type == 3/*kEdgeUniform*/)
+                {
+                    font->setColor(list[i]->attr.GetEdgeColor(), kTTF_Outline);
+                    font->setOutline(true);
+                }
+                else if (list[i]->attr.edge_type == 4/*kEdgeLeftShadow*/)
+                {
+                    font->setColor(list[i]->attr.GetEdgeColor(), kTTF_Shadow);
+                    font->setShadow(-2, +2);
+                }
+                else if (list[i]->attr.edge_type == 5/*kEdgeRightShadow*/)
+                {
+                    font->setColor(list[i]->attr.GetEdgeColor(), kTTF_Shadow);
+                    font->setShadow(+2, +2);
+                }
             }
 
             font->DrawString(surface,
diff -urNad mythtv-0.22.0-fixes22994~/libs/libmythtv/osdtypes.h mythtv-0.22.0-fixes22994/libs/libmythtv/osdtypes.h
--- mythtv-0.22.0-fixes22994~/libs/libmythtv/osdtypes.h	2009-10-14 20:32:50.000000000 -0500
+++ mythtv-0.22.0-fixes22994/libs/libmythtv/osdtypes.h	2009-12-22 23:10:08.000000000 -0600
@@ -600,7 +600,8 @@
 {
   public:
     OSDType708CC(const QString &name, TTFFont *fonts[48],
-                 int xoff, int yoff, int dispw, int disph);
+                 int xoff, int yoff, int dispw, int disph,
+                 float wmult, float hmult);    
     virtual ~OSDType708CC() {}
 
     void Reinit(float, float) {}
@@ -621,6 +622,9 @@
 
     TTFFont *m_fonts[48];
 
+    OSDTypeBox *m_box;
+    int m_ccbackground;
+    float m_wmult, m_hmult;  
     int xoffset, yoffset, displaywidth, displayheight;
 };
 
diff -urNad mythtv-0.22.0-fixes22994~/programs/mythfrontend/globalsettings.cpp mythtv-0.22.0-fixes22994/programs/mythfrontend/globalsettings.cpp
--- mythtv-0.22.0-fixes22994~/programs/mythfrontend/globalsettings.cpp	2009-12-22 21:53:33.000000000 -0600
+++ mythtv-0.22.0-fixes22994/programs/mythfrontend/globalsettings.cpp	2009-12-22 23:13:29.000000000 -0600
@@ -1959,10 +1959,10 @@
 static HostCheckBox *CCBackground()
 {
     HostCheckBox *gc = new HostCheckBox("CCBackground");
-    gc->setLabel(QObject::tr("Black background for analog closed captioning"));
+    gc->setLabel(QObject::tr("Black background for closed captioning")); 
     gc->setValue(false);
     gc->setHelpText(QObject::tr(
-                        "If enabled, analog captions will be displayed "
+                        "If enabled, captions will be displayed "
                         "over a black space for maximum contrast. Otherwise, "
                         "captions will use outlined text over the picture."));
     return gc;
